// 教育学习
import request from "@/utils/request.js"
// let djDeptId = JSON.parse(uni.getStorageSync('loginUserInfo')).djDeptId;
// let userId = JSON.parse(uni.getStorageSync('loginUserInfo')).uid;

// 1 教育学习列表
export function apiStudyList(params) {
	params.djDeptId = JSON.parse(uni.getStorageSync('loginUserInfo')).djDeptId;
	return request({
		url: `/education/getVideoList`,
		data: params
	})
}

// 2 学习类型
export function apiEducationList() {
	return request({
		url: `/enumerate/getEducationList`
	})
}

// 3 上传学习资料
export function apiUploadData(data) {
	data.djDeptId = JSON.parse(uni.getStorageSync('loginUserInfo')).djDeptId;

	return request({
		url: `/education/uploadData`,
		method: 'post',
		data
	})
}

// 4 上传1 下载2 历史数据
export function apiUploadHistoryList(params) {
	params.djDeptId = JSON.parse(uni.getStorageSync('loginUserInfo')).djDeptId;
	params.userId = JSON.parse(uni.getStorageSync('loginUserInfo')).uid;

	return request({
		url: `/education/getUploadHistoryList`,
		data: params
	})
}

// 5 上传批量删除
export function apiDeleteUploadXue(djStudyId) {
	return request({
		url: `/education/delete/${djStudyId}`,
		method: 'delete'
	})
}

// 5 创建的教育学习列表
export function apiUploadList(params) {
	params.djDeptId = JSON.parse(uni.getStorageSync('loginUserInfo')).djDeptId;

	return request({
		url: `/education/videoList`,
		data: params
	})
}

// 6 收藏
export function apiCollect(params) {
	return request({
		url: `/education/collect`,
		method: 'post',
		data: params
	})
}

// 7 点击下载时调用这个接口
export function apiClickDown(params) {
	params.djDeptId = JSON.parse(uni.getStorageSync('loginUserInfo')).djDeptId;

	return request({
		url: `/education/uploadHistory`,
		method: 'post',
		data: params
	})
}

// 8 收藏
export function apiShouChang(params) {
	return request({
		url: `/education/collect`,
		method: 'post',
		data: params
	})
}

// 9 取消收藏
export function apiDelCollection(collectId) {
	return request({
		url: `/education/cancelCollect/${collectId}`,
		method: 'delete'
	})
}

// 10 收藏列表
export function apiCollectionList(params) {
	params.djDeptId = JSON.parse(uni.getStorageSync('loginUserInfo')).djDeptId;
	return request({
		url: `/education/shouChangList`,
		method: 'get',
		data: params
	})
}

// 11 上传下载历史批量删除 -- 只删除记录，不删除真实数据
export function apiDeleteDownList(recordId) {
	return request({
		url: `/education/deleteUploadHistory/${recordId}`,
		method: 'delete',
	})
}

/**
 * 12 观看进度记录
 * @param {Object} data 
 * 	djStudyId: 视频id,
 *	schedule: 查看了第几集,
 *	userId: 用户id
 */
export function apiWatchRecords(data) {
	return request({
		url: `/education/savePlan`,
		method: 'post',
		data
	})
}

/**
 * 13 观看进度信息
 */
export function apiWatchInfo(data) {
	return request({
		url: `/education/progressInfo`,
		data
	})
}

// 14 学习心得列表
export function apiXindeList(data) {
	data.djDeptId = JSON.parse(uni.getStorageSync('loginUserInfo')).djDeptId;
	return request({
		url: `/education/videoList`,
		data
	})
}

// 15 党员下载学习心得列表
export function apiDangDownXinDeList(data) {
	return request({
		url: `/education/selectRecordInfoList`,
		data
	})
}

// [新增 党建管理2023.6.15]
// 获取每个学习类型的数量
export function apiEducTypeNum(djDeptId,userId) {
	return request({
		url: `/education/getInfo?djDeptId=${djDeptId}&userId=${userId}`
	})
}

// 修改每个学习类型未读文件数量 改成 
// 记录党员每个学习类型已读未读文件数量
export function apiClickUpdateCount(data) {
	return request({
		url: `/education/save`,
		method: "post",
		data
	})
}

// 18 统计每个党员的已读文章状态 type类型 userId登录人id
export function apiCommonIsRead(data) {
	return request({
		url: `/education/getArticleCountByUser`,
		data
	})
}

// 记录党员每个学习类型已读未读文件数量 -- 只有单元才调这个接口
// export function apiCommonEducSave(data) {
// 	return request({
// 		url: `/education/save`,
// 		method: 'post',
// 		data
// 	})
// }
